# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=cfssl
pkgver=1.6.4
pkgrel=6
pkgdesc="Cloudflare PKI and TLS toolkit"
url="https://cfssl.org/"
license="BSD-2-Clause"
arch="all !riscv64" # FTBFS
options="!check" # TODO: fix and enable tests
makedepends="go sqlite-dev"
source="https://github.com/cloudflare/cfssl/archive/v$pkgver/cfssl-$pkgver.tar.gz"

export GOFLAGS="$GOFLAGS -trimpath -modcacherw -mod=vendor -tags=libsqlite3"
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build \
		-ldflags="-X github.com/cloudflare/cfssl/cli/version.version=$pkgver" \
		-v -o bin/ ./cmd/...
}

check() {
	go test ./...
}

package() {
	install -Dm755 bin/* -t "$pkgdir"/usr/bin/
}

sha512sums="
6327d15dda24bf072958c74f4cd0bf1aa4023f935bb24da7f5655739992970fa777f6771603dd3a6edfee6cd2ed418a2fef335f7209ce88cf07674d592c3110f  cfssl-1.6.4.tar.gz
"
